﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace USERS.CYT369.COM.DAL
{
    public class CityService : USERS.CYT369.COM.DAL.DbContexts.BaseBaseService<CityService>
    {
        /// <summary>
        /// 获取所有城市
        /// </summary>
        /// <returns></returns>
        public IQueryable<USERS.CYT369.COM.MODELS.Base.City> GetCitys()
        {
            using (var ctx = base.BaseCtx)
            {
                var citys = ctx.Citys.ToList().AsQueryable();
                return citys;
            }
        }

        /// <summary>
        /// 获取城市通过ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public USERS.CYT369.COM.MODELS.Base.City GetCityByID(int id)
        {
            using(var ctx = base.BaseCtx)
            {
                var city = ctx.Citys.Where(c => c.Id == id).FirstOrDefault();
                return city;
            }
        }
    }
}
